package ynu.lcy.elememicroserviceuserauthservice9091.chain;


import ynu.lcy.elememicroservicecommon.enums.UserRoleEnum;
import ynu.lcy.elememicroservicecommon.exception.BusinessException;
import ynu.lcy.elememicroservicecommon.utils.ErrorCode;

public class AccountLockCheckHandler extends AbstractAuthenticationHandler {
    @Override
    public void handle(AuthenticationContext context) throws BusinessException {
        String role = context.getUser().getUserRole();
        UserRoleEnum mustUserRoleEnum = UserRoleEnum.getEnumByValue(role);
        if (UserRoleEnum.BAN.equals(mustUserRoleEnum)) {
            throw new BusinessException(ErrorCode.Authentication_ERROR,"账户被锁定，请联系管理员");
        }
        handleNext(context);
    }
}
